package tmsdk.common.module.update; import android.content.Context; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import com.qq.taf.jce.JceStruct; import com.xiaomi.onetrack.OneTrack; import java.io.File; import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import tmsdk.bg.tcc.TelNumberLocator; import tmsdk.common.NumMarker; import tmsdk.common.YellowPages; import tmsdk.common.creator.BaseManagerC; import tmsdk.common.creator.ManagerCreatorC; import tmsdk.common.module.qscanner.impl.AmScannerV2; import tmsdk.common.roach.nest.PowerNest; import tmsdkobf.a0; import tmsdkobf.aa; import tmsdkobf.ah; import tmsdkobf.bh; import tmsdkobf.bj; import tmsdkobf.c0; import tmsdkobf.d3; import tmsdkobf.dc; import tmsdkobf.dh; import tmsdkobf.e0; import tmsdkobf.ea; import tmsdkobf.f0; import tmsdkobf.l; import tmsdkobf.l7; import tmsdkobf.lh; import tmsdkobf.o3; import tmsdkobf.pi; import tmsdkobf.sf; import tmsdkobf.si; import tmsdkobf.t8; import tmsdkobf.v3; import tmsdkobf.x3; import tmsdkobf.xg; import tmsdkobf.y3; import tmsdkobf.ya; import tmsdkobf.zi; /* access modifiers changed from: package-private */ public final class a extends BaseManagerC { /* renamed from: b reason: collision with root package name */ private Context f1069b; private String c = null; private AtomicBoolean d = new AtomicBoolean(false); private HashMap<Long, SoftReference<IUpdateObserver>> e = new HashMap<>(); private b f; /* access modifiers changed from: package-private */ /* renamed from: tmsdk.common.module.update.a$a reason: collision with other inner class name */ public class C0042a implements t8 { /* renamed from: a reason: collision with root package name */ final /* synthetic */ long f1070a; /* renamed from: b reason: collision with root package name */ final /* synthetic */ ICheckListener f1071b; final /* synthetic */ ArrayList c; C0042a(long j, ICheckListener iCheckListener, ArrayList arrayList) { this.f1070a = j; this.f1071b = iCheckListener; this.c = arrayList; } @Override // tmsdkobf.t8 public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) { ArrayList<f0> arrayList; int i5; ICheckListener iCheckListener; a aVar; String str; StringBuilder sb; String str2; int i6; pi.a("UpdateMgr", (Object) ("[Shark]onFinish-Cmd_CSConfInfo, elapsed time:[" + (System.currentTimeMillis() - this.f1070a) + "]cmdId:[" + i2 + "]retCode:[" + i3 + "]dataRetCode: " + i4)); pi.b("UpdateMgr", "[UpdateManager] disconnect for check update data"); if (jceStruct == null) { pi.e("UpdateMgr", "null == resp"); a.this.a((a) -205, (int) this.f1071b); return; } e0 e0Var = (e0) jceStruct; if (e0Var == null || (arrayList = e0Var.f) == null) { pi.e("UpdateMgr", "(SCConfInfo)resp.vecConfInfo empty"); a.this.a((a) -205, (int) this.f1071b); } else if (arrayList.size() <= 0) { pi.a("UpdateMgr", (Object) "size: 0, no available db"); a.this.a((a) i3, (int) this.f1071b); } else if (i3 == 0) { Iterator<f0> it = e0Var.f.iterator(); int i7 = 0; while (it.hasNext()) { f0 next = it.next(); if (next != null) { StringBuilder sb2 = new StringBuilder(); sb2.append("["); int i8 = i7 + 1; sb2.append(i7); sb2.append("]resp::fileId:["); sb2.append(next.f1213b); sb2.append("]isIncreUpdate:["); sb2.append(next.f); sb2.append("]"); pi.a("UpdateMgr", (Object) sb2.toString()); UpdateInfo updateInfo = new UpdateInfo(); if (40458 == next.f1213b || UpdateConfig.getLargeMarkFileId() == (i6 = next.f1213b) || 40801 == i6 || 40800 == i6 || 40461 == i6) { str2 = ".sdb"; if (next.f) { sb = new StringBuilder(); sb.append(UpdateConfig.intToString(next.f1213b)); } else { sb = new StringBuilder(); sb.append(UpdateConfig.intToString(next.f1213b)); sb.append(str2); str = sb.toString(); updateInfo.fileName = str; updateInfo.mFileID = next.f1213b; pi.a("UpdateMgr", (Object) ("[" + i8 + "]resp::fileName:[" + updateInfo.fileName + "]url:[" + next.e + "]")); updateInfo.flag = UpdateConfig.getFlagByFileId(next.f1213b); updateInfo.type = 0; updateInfo.url = next.e; updateInfo.data1 = next; updateInfo.fileSize = next.j; this.c.add(updateInfo); i7 = i8; } } else if (next.f) { sb = new StringBuilder(); str2 = UpdateConfig.getFileNameByFileId(next.f1213b); } else { str = UpdateConfig.getFileNameByFileId(i6); updateInfo.fileName = str; updateInfo.mFileID = next.f1213b; pi.a("UpdateMgr", (Object) ("[" + i8 + "]resp::fileName:[" + updateInfo.fileName + "]url:[" + next.e + "]")); updateInfo.flag = UpdateConfig.getFlagByFileId(next.f1213b); updateInfo.type = 0; updateInfo.url = next.e; updateInfo.data1 = next; updateInfo.fileSize = next.j; this.c.add(updateInfo); i7 = i8; } sb.append(str2); sb.append(UpdateConfig.PATCH_SUFIX); str = sb.toString(); updateInfo.fileName = str; updateInfo.mFileID = next.f1213b; pi.a("UpdateMgr", (Object) ("[" + i8 + "]resp::fileName:[" + updateInfo.fileName + "]url:[" + next.e + "]")); updateInfo.flag = UpdateConfig.getFlagByFileId(next.f1213b); updateInfo.type = 0; updateInfo.url = next.e; updateInfo.data1 = next; updateInfo.fileSize = next.j; this.c.add(updateInfo); i7 = i8; } } CheckResult checkResult = new CheckResult(); l lVar = e0Var.d; String str3 = ""; checkResult.mTitle = lVar != null ? lVar.f1436b : str3; if (lVar != null) { str3 = lVar.c; } checkResult.mMessage = str3; checkResult.mUpdateInfoList = this.c; if (this.f1071b != null) { pi.a("UpdateMgr", (Object) "[callback]onCheckFinished"); this.f1071b.onCheckFinished(checkResult); } pi.a("UpdateMgr", (Object) ("title:[" + checkResult.mTitle + "]msg:[" + checkResult.mMessage + "]")); } else { pi.a("UpdateMgr", (Object) ("failed, retCode: " + i3)); if (i3 % 20 == -4) { aVar = a.this; iCheckListener = this.f1071b; i5 = -206; } else { aVar = a.this; iCheckListener = this.f1071b; i5 = -999; } aVar.a((a) i5, (int) iCheckListener); } } } /* access modifiers changed from: package-private */ public class b implements bh.a { /* renamed from: a reason: collision with root package name */ final /* synthetic */ IUpdateListener f1072a; /* renamed from: b reason: collision with root package name */ final /* synthetic */ UpdateInfo f1073b; final /* synthetic */ AtomicBoolean c; b(a aVar, IUpdateListener iUpdateListener, UpdateInfo updateInfo, AtomicBoolean atomicBoolean) { this.f1072a = iUpdateListener; this.f1073b = updateInfo; this.c = atomicBoolean; } @Override // tmsdkobf.bh.a public void a(Bundle bundle) { } @Override // tmsdkobf.bh.a public void b(Bundle bundle) { int i = bundle.getInt("key_errcode"); if (this.f1072a != null) { pi.a("UpdateMgr", (Object) ("[callback]onUpdateEvent:[" + i + "]")); this.f1072a.onUpdateEvent(this.f1073b, i); } this.c.set(true); UpdateInfo updateInfo = this.f1073b; updateInfo.errorCode = i; updateInfo.errorMsg = bundle.getString("key_errorMsg"); this.f1073b.downSize = bundle.getInt("key_downSize"); this.f1073b.fileSize = bundle.getInt("key_total"); this.f1073b.sdcardStatus = bundle.getInt("key_sdcardstatus"); this.f1073b.downType = bundle.getByte("key_downType"); } } /* access modifiers changed from: package-private */ public class c implements dh.a { /* renamed from: a reason: collision with root package name */ final /* synthetic */ UpdateInfo f1074a; c(UpdateInfo updateInfo) { this.f1074a = updateInfo; } @Override // tmsdkobf.dh.a public boolean a(String str) { f0 f0Var = (f0) this.f1074a.data1; if (f0Var == null) { return true; } StringBuilder sb = new StringBuilder(); sb.append("isMatch confSrc.md5Bin = "); byte[] bArr = f0Var.c; sb.append(bArr == null ? "null" : Arrays.toString(bArr)); Log.e("UpdateMgr", sb.toString()); String c = xg.c(f0Var.c); int i = f0Var.m; if (i == 2) { File parentFile = new File(str).getParentFile(); String str2 = parentFile.getPath() + File.separator + "tempZip" + File.separator; try { File file = new File(str2); if (file.exists()) { dc.a(file); } l7.a(str, str2); File[] listFiles = file.listFiles(); if (listFiles != null) { if (listFiles.length != 0) { if (listFiles.length != 1) { return false; } if (str.length() > 8) { str = str.substring(0, str.length() - 8); } else { str = str + ".tmp"; } File file2 = new File(str); if (file2.exists()) { file2.delete(); } dc.a(listFiles[0], file2); dc.a(file); } } return false; } catch (Exception e) { pi.a("UpdateMgr", "unzip num mark file failed", e); return false; } } else if (i == 1) { pi.b("UpdateMgr", (Object) "num mark file should not zip encrypt"); return false; } else { pi.c("UpdateMgr", (Object) "normal num mark file"); } if (TextUtils.isEmpty(str)) { return false; } boolean a2 = a.this.a((a) str, c); pi.c(NumMarker.Tag, (Object) ("DataMd5Cheker isMatch() isMth: " + a2)); return a2; } } /* access modifiers changed from: package-private */ public class d implements dh.a { /* renamed from: a reason: collision with root package name */ final /* synthetic */ UpdateInfo f1076a; d(UpdateInfo updateInfo) { this.f1076a = updateInfo; } @Override // tmsdkobf.dh.a public boolean a(String str) { pi.c("UpdateMgr", (Object) ("isMatch filePath = " + str)); f0 f0Var = (f0) this.f1076a.data1; if (f0Var == null) { return true; } StringBuilder sb = new StringBuilder(); sb.append("isMatch confSrc.md5Bin = "); byte[] bArr = f0Var.c; sb.append(bArr == null ? "null" : Arrays.toString(bArr)); pi.c("UpdateMgr", (Object) sb.toString()); return a.this.b(str, xg.c(f0Var.c)); } } /* access modifiers changed from: package-private */ public class e implements t8 { /* renamed from: a reason: collision with root package name */ final /* synthetic */ long f1078a; /* renamed from: b reason: collision with root package name */ final /* synthetic */ AtomicReference f1079b; final /* synthetic */ Object c; e(long j, AtomicReference atomicReference, Object obj) { this.f1078a = j; this.f1079b = atomicReference; this.c = obj; } @Override // tmsdkobf.t8 public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) { int i5; AtomicReference atomicReference; String str; String str2; pi.a("UpdateMgr", (Object) ("[Shark]onFinish-Cmd_CSUpdateVirusInfos, elapsed time:[" + (System.currentTimeMillis() - this.f1078a) + "]cmdId:[" + i2 + "]retCode:[" + i3 + "]dataRetCode: " + i4)); pi.b("UpdateMgr", "[UpdateManager] disconnect for updateVirus"); StringBuilder sb = new StringBuilder(); sb.append(i3); sb.append(";"); sb.append(i4); sf.c(1320094, sb.toString()); if (i3 == 0 && i4 == 0) { if (jceStruct != null) { o3 o3Var = (o3) jceStruct; y3 y3Var = o3Var.f1543b; ArrayList<x3> arrayList = o3Var.c; if (y3Var == null) { str2 = "UpdateMgr"; str = "SCUpdateVirusInfos.serverinfo is null!"; } else if (y3Var.a()) { pi.e("UpdateMgr", "need update engine, donnot update virus base!"); } else if (arrayList == null || arrayList.size() <= 0) { pi.e("UpdateMgr", "no update info, virusInfoList: " + arrayList); } else { String b2 = zi.b(a.this.f1069b, (long) UpdateConfig.UPDATE_FLAG_VIRUS_BASE); int a2 = AmScannerV2.a(a.this.f1069b, b2, y3Var, arrayList); this.f1079b.set(Integer.valueOf(a2)); if (a2 != 0) { pi.e("UpdateMgr", "amf file error, delete:[" + b2 + "]"); ah.a(b2); } pi.a("UpdateMgr", (Object) ("native updateBase, size: " + arrayList.size() + " ret: " + a2)); } } else { str2 = "UpdateMgr"; str = "SCUpdateVirusInfos is null!"; } pi.e(str2, str); this.f1079b.set(-6); } else { pi.e("UpdateMgr", "retCode != 0 || dataRetCode != 0"); if (i3 % 20 == -4) { atomicReference = this.f1079b; i5 = -206; } else { atomicReference = this.f1079b; i5 = -999; } atomicReference.set(Integer.valueOf(i5)); if (i4 != 0) { this.f1079b.set(-205); } } synchronized (this.c) { this.c.notify(); } } } a() { } private List<c0> a(long j) { c0 a2; ArrayList arrayList = new ArrayList(); if (j == UpdateConfig.UPDATA_FLAG_NUM_MARK) { arrayList.add(a(40458)); a2 = a(UpdateConfig.getLargeMarkFileId()); } else if (j == 2) { a2 = zi.a(50001, zi.a(this.f1069b, 50001, ".sdb")); } else if (j == UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large) { a2 = zi.c(40461, zi.a(this.f1069b, 40461, ".sdb")); if (a2 != null) { pi.c("gjj", (Object) ("fileId:" + a2.f1138b + " timestamp:" + a2.d + " pfutimestamp:" + a2.e + " version:" + a2.g)); } return arrayList; } else { a2 = zi.a(this.f1069b, j); } arrayList.add(a2); return arrayList; } private c0 a(int i) { c0 b2 = zi.b(i, zi.a(this.f1069b, i, ".sdb")); if (b2 == null) { b2 = new c0(); b2.f1138b = i; b2.c = new byte[0]; b2.d = 0; } if (b2.c == null) { b2.c = xg.a(""); } pi.c(NumMarker.Tag, (Object) ("fileId:" + b2.f1138b + " timestamp:" + b2.d + " pfutimestamp:" + b2.e + " version:" + b2.g)); return b2; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(int i, ICheckListener iCheckListener) { if (iCheckListener != null) { if (i != 0) { pi.a("UpdateMgr", (Object) ("[callback]onCheckEvent:[" + i + "]")); iCheckListener.onCheckEvent(i); } pi.a("UpdateMgr", (Object) "[callback]onCheckFinished--null"); iCheckListener.onCheckFinished(null); } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private boolean a(String str, String str2) { String b2 = ((lh) ManagerCreatorC.getManager(lh.class)).b(str); return (str2 == null || b2 == null || !str2.toLowerCase().equals(b2.toLowerCase())) ? false : true; } private boolean a(c0 c0Var, String str) { String str2; if (c0Var == null) { str2 = "isMd5Match() confInfoFromFile is null"; } else { byte[] bArr = c0Var.c; if (bArr == null || bArr.length == 0) { str2 = "isMd5Match() confInfoFromFile.md5Bin is empty"; } else { String a2 = xg.a(bArr); if (str == null || a2 == null) { str2 = "isMd5Match() md5FromUpdateInfo or md5FromFileHeader is null"; } else { pi.c("UpdateMgr", (Object) ("isMd5Match() md5FromUpdateInfo:" + str.toLowerCase() + " md5FromFileHeader:" + a2.toLowerCase())); if (!str.toLowerCase().equals(a2.toLowerCase())) { str2 = "isMd5Match() md5FromUpdateInfo and md5FromFileHeader is not match"; } else { pi.c("UpdateMgr", (Object) "isMd5Match() = true"); return true; } } } } pi.c("UpdateMgr", (Object) str2); return false; } private int b(int i) { AtomicReference atomicReference = new AtomicReference(0); Context context = this.f1069b; v3 c2 = zi.c(context, zi.b(context, (long) UpdateConfig.UPDATE_FLAG_VIRUS_BASE)); if (c2 != null) { c2.d = 3; c2.e = i; d3 d3Var = new d3(); d3Var.f1177b = c2; long currentTimeMillis = System.currentTimeMillis(); Object obj = new Object(); ya h = aa.h(); pi.a("UpdateMgr", (Object) ("[Shark]Cmd_CSUpdateVirusInfos, sendShark, guid:[" + h.a() + "]")); h.a(2006, d3Var, new o3(), PowerNest.SHARK_HTTP, new e(currentTimeMillis, atomicReference, obj), 180000); synchronized (obj) { try { obj.wait(); } catch (Exception e2) { pi.c("UpdateMgr", "SCAN_LOCK.wait(): " + e2, e2); } } } else { pi.e("UpdateMgr", "getVirusClientInfo return null!"); atomicReference.set(-2); } return ((Integer) atomicReference.get()).intValue(); } @Deprecated private c0 b(long j) { if (j != 4) { if (j == UpdateConfig.UPDATE_FLAG_VIRUS_BASE || j == UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG) { Context context = this.f1069b; return zi.b(context, zi.b(context, j)); } else if (j == 2) { return zi.a(50001, zi.b(this.f1069b, j)); } else { if (j != 2147483648L) { return zi.a(this.f1069b, j); } } } return null; } private void b(UpdateInfo updateInfo) { TelNumberLocator telNumberLocator = TelNumberLocator.getDefault(this.f1069b); f0 f0Var = (f0) updateInfo.data1; if (f0Var.f) { telNumberLocator.patchLocation(this.c + File.separator + updateInfo.fileName, xg.a(f0Var.c)); } telNumberLocator.reload(); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private boolean b(String str, String str2) { pi.c("UpdateMgr", (Object) ("isYellowPageMd5Match() filePath:" + str + " md5FromUpdateInfo:" + str2)); return a(zi.c(40461, str), str2); } private void c(UpdateInfo updateInfo) { String str = this.c + File.separator + updateInfo.fileName; f0 f0Var = (f0) updateInfo.data1; if (f0Var != null) { int i = f0Var.m; if (i == 2) { String str2 = this.c + File.separator + "zipTemp" + File.separator; try { File file = new File(str2); if (file.exists()) { dc.a(file); } l7.a(str, str2); File[] listFiles = file.listFiles(); if (listFiles == null) { return; } if (listFiles.length != 0) { if (listFiles.length == 1) { File file2 = new File(str); if (file2.exists()) { file2.delete(); } dc.a(listFiles[0], file2); dc.a(file); } else { return; } } else { return; } } catch (Exception e2) { pi.a("UpdateMgr", "unzip num mark big file failed", e2); return; } } else if (i == 1) { pi.b("UpdateMgr", (Object) "num mark big file should not zip encrypt"); return; } else { pi.c("UpdateMgr", (Object) "normal num mark big file"); } String c2 = !f0Var.f ? xg.c(f0Var.c) : xg.c(f0Var.g); lh lhVar = (lh) ManagerCreatorC.getManager(lh.class); if (lhVar == null) { return; } if (lhVar.a(str, c2) == 0) { lhVar.e(); } else { lhVar.c(); } } } private void d(UpdateInfo updateInfo) { String str = this.c + File.separator + updateInfo.fileName; f0 f0Var = (f0) updateInfo.data1; if (f0Var != null) { int i = f0Var.m; if (i == 2) { String str2 = this.c + File.separator + "zipTemp" + File.separator; try { File file = new File(str2); if (file.exists()) { dc.a(file); } l7.a(str, str2); File[] listFiles = file.listFiles(); if (listFiles == null) { return; } if (listFiles.length != 0) { if (listFiles.length == 1) { File file2 = new File(str); if (file2.exists()) { file2.delete(); } dc.a(listFiles[0], file2); dc.a(file); } else { return; } } else { return; } } catch (Exception e2) { pi.a("UpdateMgr", "unzip num mark file failed", e2); return; } } else if (i == 1) { pi.b("UpdateMgr", (Object) "num mark file should not zip encrypt"); return; } else { pi.c("UpdateMgr", (Object) "normal num mark file"); } String c2 = !f0Var.f ? xg.c(f0Var.c) : xg.c(f0Var.g); lh lhVar = (lh) ManagerCreatorC.getManager(lh.class); if (lhVar == null) { return; } if (lhVar.b(str, c2) == 0) { lhVar.e(); } else { lhVar.c(); } } } private void e(UpdateInfo updateInfo) { String str = this.c + File.separator + updateInfo.fileName; f0 f0Var = (f0) updateInfo.data1; if (f0Var != null) { int i = f0Var.m; if (i == 2) { String str2 = this.c + File.separator + "zipTemp" + File.separator; try { File file = new File(str2); if (file.exists()) { dc.a(file); } l7.a(str, str2); File[] listFiles = file.listFiles(); if (listFiles == null) { return; } if (listFiles.length != 0) { if (listFiles.length == 1) { File file2 = new File(str); if (file2.exists()) { file2.delete(); } dc.a(listFiles[0], file2); dc.a(file); } else { return; } } else { return; } } catch (Exception e2) { pi.a("UpdateMgr", "unzip num mark big file failed", e2); return; } } else if (i == 1) { pi.b("UpdateMgr", (Object) "num mark big file should not zip encrypt"); return; } else { pi.c("UpdateMgr", (Object) "normal num mark big file"); } if (!f0Var.f) { xg.c(f0Var.c); } else { xg.c(f0Var.g); } YellowPages instance = YellowPages.getInstance(); if (instance != null && instance.update(str) != 0) { ((lh) ManagerCreatorC.getManager(lh.class)).d(); } } } public void a(long j, ICheckListener iCheckListener) { String str; StringBuilder sb; int i; pi.a("UpdateMgr", (Object) ("check-checkFlag:[" + j + "]")); int i2 = 0; this.d.set(false); if (iCheckListener != null) { pi.a("UpdateMgr", (Object) "[callback]onCheckStarted"); iCheckListener.onCheckStarted(); } long prepareCheckFlag = UpdateConfig.prepareCheckFlag(j); ArrayList arrayList = new ArrayList(); if (!ea.e().b()) { CheckResult checkResult = new CheckResult(); checkResult.mTitle = "Warning"; checkResult.mMessage = "Expired! Please contact TMS(Tencent Mobile Secure) group."; checkResult.mUpdateInfoList = arrayList; if (iCheckListener != null) { pi.a("UpdateMgr", (Object) "[callback]onCheckFinished--Licence Expired"); iCheckListener.onCheckFinished(checkResult); } } else if (this.d.get()) { if (iCheckListener != null) { pi.a("UpdateMgr", (Object) "[callback]111onCheckCanceled"); iCheckListener.onCheckCanceled(); } a(0, iCheckListener); } else { ArrayList<c0> arrayList2 = new ArrayList<>(); long[] jArr = UpdateConfig.UPDATE_FLAGS; int length = jArr.length; int i3 = 0; while (i3 < length) { long j2 = jArr[i3]; if ((j2 & prepareCheckFlag) != 0) { long j3 = UpdateConfig.UPDATA_FLAG_NUM_MARK; if (j2 != UpdateConfig.UPDATA_FLAG_NUM_MARK) { j3 = 2; if (j2 != 2) { j3 = UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large; if (j2 != UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large) { c0 b2 = b(j2); if (b2 == null) { b2 = new c0(); b2.f1138b = UpdateConfig.getFileIdByFlag(j2); b2.c = new byte[i2]; b2.d = i2; } if (b2.c == null) { b2.c = xg.a(""); } if (j2 == UpdateConfig.UPDATE_FLAG_VIRUS_BASE) { pi.a("UpdateMgr", (Object) "req::UpdateConfig.UPDATE_FLAG_VIRUS_BASE"); sb = new StringBuilder(); sb.append("req::fileId:["); sb.append(b2.f1138b); sb.append("]timestamp:["); i = b2.d; } else if (j2 == UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG) { pi.a("UpdateMgr", (Object) "req::UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG"); sb = new StringBuilder(); sb.append("req::fileId:["); i = b2.f1138b; } else { if (j2 == UpdateConfig.UPDATE_FLAG_SMS_CUSTOM_BLOCK_RULE) { str = "rule"; } else if (j2 == UpdateConfig.UPDATE_FLAG_SMS_CUSTOM_BLOCK_MODEL) { str = OneTrack.Param.MODEL; } else if (j2 == UpdateConfig.UPDATE_FLAG_SMS_CUSTOM_BLOCK_DIC) { str = "dic"; } else if (j2 == UpdateConfig.UPDATE_FLAG_YELLOW_PAGE_OFFLINE_DATABASE) { str = "yellow page offline database"; } else { if (j2 == UpdateConfig.UPDATE_FLAG_YELLOW_PAGE_OFFLINE_KEYWORDS) { str = "yellow page offline keywords"; } arrayList2.add(b2); } pi.a("UpdateMgr", (Object) str); arrayList2.add(b2); } sb.append(i); sb.append("]"); str = sb.toString(); pi.a("UpdateMgr", (Object) str); arrayList2.add(b2); } } } arrayList2.addAll(a(j3)); } i3++; i2 = 0; } a0 a0Var = new a0(); a0Var.f1095b = arrayList2; a0Var.c = 1; e0 e0Var = new e0(); long currentTimeMillis = System.currentTimeMillis(); ya h = aa.h(); pi.a("UpdateMgr", (Object) ("[Shark]Cmd_CSConfInfo, sendShark, guid:[" + h.a() + "]")); pi.a("UpdateMgr", "[UpdateManager] connect for check update data"); h.a(108, a0Var, e0Var, 0, new C0042a(currentTimeMillis, iCheckListener, arrayList)); } } public void a(UpdateInfo updateInfo) { IUpdateObserver iUpdateObserver; synchronized (this.e) { for (Map.Entry<Long, SoftReference<IUpdateObserver>> entry : this.e.entrySet()) { if (!((entry.getKey().longValue() & updateInfo.flag) == 0 || (iUpdateObserver = entry.getValue().get()) == null)) { iUpdateObserver.onChanged(updateInfo); } } } } public void addObserver(long j, IUpdateObserver iUpdateObserver) { synchronized (this.e) { if (iUpdateObserver != null) { this.e.put(Long.valueOf(j), new SoftReference<>(iUpdateObserver)); } } } public void cancel() { this.d.set(true); } public String getFileSavePath() { return this.c; } @Override // tmsdkobf.q9 public int getSingletonType() { return 1; } @Override // tmsdkobf.q9 public void onCreate(Context context) { this.f1069b = context; this.c = context.getFilesDir().getAbsolutePath(); this.f = b.b(); } public void removeObserver(long j) { synchronized (this.e) { this.e.remove(Long.valueOf(j)); } } /* JADX WARNING: Removed duplicated region for block: B:109:0x027e */ /* JADX WARNING: Removed duplicated region for block: B:110:0x028b */ /* JADX WARNING: Removed duplicated region for block: B:121:0x02b3 A[SYNTHETIC] */ /* JADX WARNING: Removed duplicated region for block: B:123:0x02bc A[SYNTHETIC] */ /* JADX WARNING: Removed duplicated region for block: B:28:0x011c */ /* JADX WARNING: Removed duplicated region for block: B:86:0x0206 */ /* JADX WARNING: Removed duplicated region for block: B:92:0x022e */ public boolean update(List<UpdateInfo> list, IUpdateListener iUpdateListener) { int i; long j; c0 c0Var; int b2; int a2; int i2; pi.a("UpdateMgr", (Object) ("update-updateInfoList:[" + list + "]updateListener:[" + iUpdateListener + "]")); this.d.set(false); if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) "[callback]onUpdateStarted"); iUpdateListener.onUpdateStarted(); } if (!ea.e().b()) { if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) "[callback]00onUpdateFinished"); iUpdateListener.onUpdateFinished(); } return false; } else if (this.d.get()) { if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) "[callback]onUpdateCanceled"); iUpdateListener.onUpdateCanceled(); pi.a("UpdateMgr", (Object) "[callback]11onUpdateFinished"); iUpdateListener.onUpdateFinished(); } return false; } else { AtomicBoolean atomicBoolean = new AtomicBoolean(false); pi.a("UpdateMgr", (Object) ("updateInfoList size: " + list.size())); pi.c("UpdateMgr", "[net][https://mmgr.gtimg.com/qqsecure_config_update/qqsecure_config_update][UpdateManager] connect for update"); int i3 = 1; int i4 = 0; boolean z = true; while (true) { if (i4 >= list.size()) { break; } atomicBoolean.set(false); UpdateInfo updateInfo = list.get(i4); if (updateInfo == null) { i = i3; } else { pi.a("UpdateMgr", (Object) ("[" + i4 + "]updateInfo fileName:[" + updateInfo.fileName + "]url:[" + updateInfo.url + "]")); if (list.size() == i3) { if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) ("[callback]onProgressChanged:[" + i4 + "]")); i2 = 50; } j = updateInfo.flag; int i5 = 40458; if (j != UpdateConfig.UPDATE_FLAG_VIRUS_BASE || j == UpdateConfig.UPDATE_FLAG_VIRUS_BASE_ENG) { b2 = b(1); updateInfo.downType = 2; if (b2 != 0) { atomicBoolean.set(true); updateInfo.errorCode = b2; if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) ("[callback]onUpdateEvent:[" + b2 + "]")); iUpdateListener.onUpdateEvent(updateInfo, b2); } } if (!atomicBoolean.get()) { a(updateInfo); i = 1; updateInfo.success = 1; int largeMarkFileId = UpdateConfig.getLargeMarkFileId(); int i6 = updateInfo.mFileID; if (largeMarkFileId == i6) { i5 = UpdateConfig.getLargeMarkFileId(); } else if (40458 != i6) { i5 = 40800; if (40800 != i6) { int i7 = 40461; if (40461 != i6) { i7 = 40801; if (40801 != i6) { c0Var = 50001 == i6 ? zi.a(50001, zi.a(this.f1069b, 50001, ".sdb")) : b(updateInfo.flag); if (c0Var != null) { updateInfo.checkSum = xg.a(c0Var.c); updateInfo.timestamp = c0Var.d; } } } c0Var = zi.c(i7, zi.a(this.f1069b, i7, ".sdb")); if (c0Var != null) { } } } c0Var = a(i5); if (c0Var != null) { } } else { i = 1; updateInfo.success = 0; updateInfo.downnetType = (byte) si.d().a(); updateInfo.downNetName = si.c(); updateInfo.rssi = bj.a(5); } this.f.a(updateInfo); if (this.d.get()) { if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) "[callback]onUpdateCanceled"); iUpdateListener.onUpdateCanceled(); } } } else { if (!(j == 2147483648L || updateInfo == null || updateInfo.url == null)) { dh dhVar = new dh(this.f1069b); dhVar.b(this.c + "/"); dhVar.a(updateInfo.fileName); dhVar.a(new b(this, iUpdateListener, updateInfo, atomicBoolean)); long j2 = updateInfo.flag; String str = null; dh.a cVar = j2 == UpdateConfig.UPDATA_FLAG_NUM_MARK ? new c(updateInfo) : j2 == UpdateConfig.UPDATE_FLAG_YELLOW_PAGEV2_Large ? new d(updateInfo) : null; pi.a("UpdateMgr", (Object) "before invoke httpGetFile.doGetFile()"); while (true) { a2 = dhVar.a(str, updateInfo.url, false, cVar); if (a2 != -7) { break; } str = null; } if (!atomicBoolean.get() && updateInfo.flag == 2 && a2 == 0) { b(updateInfo); } if (!atomicBoolean.get() && 40458 == updateInfo.mFileID && a2 == 0) { d(updateInfo); } if (!atomicBoolean.get() && UpdateConfig.getLargeMarkFileId() == updateInfo.mFileID && a2 == 0) { c(updateInfo); } if (!atomicBoolean.get() && 40800 == updateInfo.mFileID && a2 == 0) { d(updateInfo); } if (!atomicBoolean.get() && 40461 == updateInfo.mFileID && a2 == 0) { e(updateInfo); } if (!atomicBoolean.get() && 40801 == updateInfo.mFileID && a2 == 0) { e(updateInfo); } if (a2 != 0) { updateInfo.errorCode = a2; } } if (!atomicBoolean.get()) { } this.f.a(updateInfo); if (this.d.get()) { } } z = false; if (!atomicBoolean.get()) { } this.f.a(updateInfo); if (this.d.get()) { } } else { if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) ("[callback]onProgressChanged:[" + i4 + "]")); i2 = (i4 * 100) / list.size(); } j = updateInfo.flag; int i52 = 40458; if (j != UpdateConfig.UPDATE_FLAG_VIRUS_BASE) { } b2 = b(1); updateInfo.downType = 2; if (b2 != 0) { } if (!atomicBoolean.get()) { } this.f.a(updateInfo); if (this.d.get()) { } } iUpdateListener.onProgressChanged(updateInfo, i2); j = updateInfo.flag; int i522 = 40458; if (j != UpdateConfig.UPDATE_FLAG_VIRUS_BASE) { } b2 = b(1); updateInfo.downType = 2; if (b2 != 0) { } if (!atomicBoolean.get()) { } this.f.a(updateInfo); if (this.d.get()) { } } i4++; i3 = i; } if (iUpdateListener != null) { pi.a("UpdateMgr", (Object) "[callback]onUpdateFinished"); iUpdateListener.onUpdateFinished(); this.f.a(); } pi.c("UpdateMgr", "[net][https://mmgr.gtimg.com/qqsecure_config_update/qqsecure_config_update][UpdateManager] disconnect for update"); return z; } } }